<html>
<head><meta charset="utf-8"><title>get span from an AssociatedItem · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/get.20span.20from.20an.20AssociatedItem.html">get span from an AssociatedItem</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="152219238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/get%20span%20from%20an%20AssociatedItem/near/152219238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mikeyhew <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/get.20span.20from.20an.20AssociatedItem.html#152219238">(Dec 19 2018 at 22:50)</a>:</h4>
<p>I'm replacing <code>bug!</code> with <code>delay_span_bug</code> and need to pass a span. I have an <code>&amp;ty::AssociatedItem&lt;'tcx&gt;</code>, how do I get the span from that? It has a <code>def_id</code> field, so presumably there is some function you can pass that to to get a span but I'm having a hard time finding it</p>



<a name="152221610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/get%20span%20from%20an%20AssociatedItem/near/152221610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mikeyhew <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/get.20span.20from.20an.20AssociatedItem.html#152221610">(Dec 19 2018 at 23:35)</a>:</h4>
<p>OK it's pretty simple: <code>tcx.def_span(def_id)</code>. According to <span class="user-mention" data-user-id="124069">@Alexander Regueiro</span>  on Discord, it might only work when the def id is local to the current crate, but it works for the code I'm working on.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>